#/usr/local/python36/bin/python3.6
#-*- coding:utf-8 -*-
import logging,logging.handlers,logging.config ,sys
from logging.handlers import RotatingFileHandler,TimedRotatingFileHandler
from urllib import parse, request

logging.config.fileConfig("..\logging.conf")
logger = logging.getLogger("SNS")


def send_sns(contents):
    # status1 = ''.join(contents)
    content_data = contents
    url = ""
    try:
        postdata=parse.urlencode({
            "action": "send",
            "userid": "",
            "account": "",
            "password": "",
            "mobile": "",
            "content": content_data,
            "sendTime": "",
            "extno": ""
        }).encode('utf-8')
        req = request.Request(url,postdata)
        req.add_header("Content-Type","application/x-www-form-urlencoded;charset=utf-8")
        r = request.urlopen(req)
        logger.debug(r.read().decode('utf-8')+"----"+content_data)
    except BaseException as b:
        _log_err = "send_sns函数执行失败 --》" + str(b)
        logger.error(_log_err)
